package com.share.lottery.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.lidroid.xutils.BitmapUtils;
import com.share.lottery.R;
import com.share.lottery.model.BulletinBean;
import com.share.lottery.model.CaiboRmdBean;

/**
 * @author py
 *开奖公告
 */
public class KjggAdapter extends BaseAdapter {
	private BitmapUtils bitmapUtils;
	private List<BulletinBean> userList = new ArrayList<BulletinBean>();
	private  Context context;
	public KjggAdapter(Context context) {
		this.context = context;
		if (bitmapUtils == null) {
			bitmapUtils = new BitmapUtils(context);
		}
	}
	public int getCount() {

		return userList.size();
	}


	public BulletinBean getItem(int arg0) {

		return userList.get(arg0);
	}


	public long getItemId(int arg0) {

		return arg0;
	}


	public View getView(int position, View convertView, ViewGroup arg2) {
		BulletinBean caiboRmdBean = userList.get(position);
		ViewHolder viewHolder = null;
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(
					R.layout.item_kjgg, null);
			viewHolder = new ViewHolder();
			viewHolder.imgKind = (ImageView) convertView.findViewById(R.id.img_kind);
			viewHolder.tvKind = (TextView) convertView.findViewById(R.id.tv_kind);

			viewHolder.tvTime = (TextView) convertView.findViewById(R.id.tv_time);

			viewHolder.tvQs = (TextView) convertView.findViewById(R.id.tv_user_name);
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		viewHolder.tvTime.setText(caiboRmdBean.getOpenTime());
		viewHolder.tvKind.setText(caiboRmdBean.getName());
		viewHolder.tvQs.setText(caiboRmdBean.getIssue());

		bitmapUtils.display(viewHolder.imgKind, caiboRmdBean.getImgPath());


		return convertView;
	}
	class ViewHolder {
		TextView tvTime;//时间
		ImageView imgKind;//
		TextView tvKind;//彩票种类


		TextView tvQs;//第几期s
		TextView one;
		TextView two;
		TextView three;
		TextView four;
		TextView five;
		TextView sex;
		TextView seven;
		



	}

	/**
	 * 添加数据
	 * 
	 * @param rows
	 */
	public void addDatas(List<BulletinBean> rows) {

		userList.addAll(rows);

		notifyDataSetChanged();
	}

	/**
	 * 清空数据
	 */
	public void clearDatas() {

		userList.clear();
		notifyDataSetChanged();
	}

}
